package com.pansoft.openplanet.adapter;

import android.widget.ImageView;
import com.chad.library.adapter.base.BaseItemDraggableAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.efounder.chat.model.AppConstant;
import com.efounder.chat.utils.LXGlideImageLoader;
import com.pansoft.newasset.bean.MenuBean;
import com.pansoft.openplanet.R;

import java.util.List;

/**
 * @author : zzj
 * @e-mail : zhangzhijun@pansoft.com
 * @date : 2019/4/25 15:10
 * @desc : 编辑应用顶部拖拽的adapter
 * @version: 1.0
 */
public class AssetEditAppDragAdapter extends BaseItemDraggableAdapter<MenuBean, BaseViewHolder> {


    public AssetEditAppDragAdapter(int layoutResId, List<MenuBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MenuBean item) {
        helper.setText(R.id.tv_title,item.getName());
        String filepath = AppConstant.APP_ROOT + "/res/unzip_res/menuImage/" + item.getIcon();
        LXGlideImageLoader.getInstance().displayImage(mContext, (ImageView) helper.getView(R.id.iv_pic),
                "file://" + filepath);
        helper.setGone(R.id.iv_operation_app,true);
        if(item.isShow()){
            helper.setImageResource(R.id.iv_operation_app,R.drawable.ic_asset_edit_app_minus);
        }else {
            helper.setImageResource(R.id.iv_operation_app,R.drawable.ic_asset_edit_app_add);
        }
        helper.addOnClickListener(R.id.iv_operation_app);
    }
}
